const app = getApp();
const call = require('../../utils/request.js');
Page({
  /**
   * 页面的初始数据
   */
  data: {
    type: 2, //视频1 图文2
    order: null //订单
  },

  onLoad: function (options) {
    this.setData({
      type:options.type,
      order:options.order
    })
  },

  onReady: function () {

  },

  onShow: function () {

  },

  onHide: function () {
    
  },

  // 立即咨询
  goVideo() {
    const trade_no = this.data.order;
    console.log("立即咨询订单",trade_no)
    wx.showLoading({
      title: '正在加载',
      mask:true
    })
    call.post('/api/camera/gen_trtc_sign',{user_id:app.globalData.sid}).then( (res1)=> {
      wx.hideLoading();
      console.log('获取签名',res1)
      if(res1.data.code == 0){
        const d = res1.data.data;
        wx.navigateTo({url:`../../interrogation/video/video?sdkAppid=${d.sdkAppid}&userSign=${d.userSgin}&tradeNo=${trade_no}`})
      }else{
        wx.showToast({
          title: '获取视频签名失败',
          icon:'none'
        })
      }
    })
  },

  // 返回
  goBack() {
    wx.switchTab({
      url: '../../pages/interrogation/interrogation',
    });
  },
  
})